package com.by.facade.enums.clue;

import com.by.facade.dto.clue.ClueWorkbenchConditionConvertAfterWDTO;
import com.by.toolkit.enums.FlagEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2024/4/9 12:07 PM
 */


@AllArgsConstructor
public enum RegionTypeEnum {

    RISK(1, "风控", after -> {}),

    MULTI_REGION(2, "多ip", after -> after.setMultiRegionFlag(FlagEnum.YES.getCode())),
    ;


    @Getter
    private final Integer type;

    private final String desc;

    @Getter
    private final Consumer<ClueWorkbenchConditionConvertAfterWDTO> consumer;

    private static final Map<Integer, RegionTypeEnum> MAP;

    static {
        MAP = Stream.of(RegionTypeEnum.values()).collect(Collectors.toMap(RegionTypeEnum::getType, Function.identity()));
    }

    public static RegionTypeEnum resolveByType(Integer type) {

        return MAP.get(type);
    }


}
